<?php

namespace app\index\controller;


class Article extends Base
{
    public function index()
    {
        $article = model('article')->with('comments')->find(input('id'));
        return view()->assign([
            "article" => $article,
            'comments' => $article['comments'],
            "tags" => explode("|", $article['tags'])
        ]);
    }

    //文章评论
    public function comment()
    {
        $data = [
            "article_id" => input('post.article_id'),
            "member_id" => input('post.member_id'),
            "content" => input('post.content')
        ];
        $result = model('comment')->add($data);
        if ($result == 1){
            $this->success('评论成功');
        }else{
            $this->error($result);
        }
    }
}
